#include "State.h"
#include "UIButton.h"

State::State()
{
	m_pScreen = new UIScreen();
	LPDIRECT3DTEXTURE9 textures[4];
	//0 for normal state:
	D3DXCreateTextureFromFileEx(g_pD3dDevice, TEXT("abutton0.png"), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &textures[0]);
	//1 for focused or mousehover state.
	D3DXCreateTextureFromFileEx(g_pD3dDevice, TEXT("abutton1.png"), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &textures[1]);
	//2 for pushing.
	D3DXCreateTextureFromFileEx(g_pD3dDevice, TEXT("abutton2.png"), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &textures[2]);
	//3 for disable state
	D3DXCreateTextureFromFileEx(g_pD3dDevice, TEXT("abutton3.png"), D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &textures[3]);
	UIButton *aButton = new UIButton(textures, m_pScreen);
	m_pScreen->add(aButton);
}

State::~State()
{

}

void State::drawUI()
{
	m_pScreen->draw();
}

void State::draw()
{

}

void State::render()
{
	draw();
	drawUI();
}

LRESULT State::msgProc(HWND hWnd, UINT p_uMsg, WPARAM p_wParam, LPARAM p_lParam )
{
	return m_pScreen->msgProc(hWnd, p_uMsg, p_wParam, p_lParam);
}

void State::update( float p_dt )
{
	
}
